package com.jetbrains.edu.uiOnboarding.steps

import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import com.jetbrains.edu.uiOnboarding.EduUiOnboardingAnimationData
import com.jetbrains.edu.uiOnboarding.stepsGraph.GraphData
import com.jetbrains.edu.uiOnboarding.stepsGraph.ZhabaData
import com.jetbrains.edu.uiOnboarding.stepsGraph.ZhabaStep
import kotlinx.coroutines.CoroutineScope

/**
 * This step does not have any actions, it always yields the transition [outboundTransition], and when the step is
 * performed, it returns the data, generated by [dataProvider].
 *
 * Such a step is intended mostly to be the initial or the final step of the step graph.
 */
class NoOpStep<StepData: ZhabaData> internal constructor(
  override val stepId: String,
  private val outboundTransition: String,
  private val dataProvider: (data: EduUiOnboardingAnimationData) -> StepData
): ZhabaStep<StepData, GraphData.EMPTY> {

  override fun performStep(
    project: Project,
    data: EduUiOnboardingAnimationData
  ): StepData = dataProvider(data)

  override suspend fun executeStep(stepData: StepData, graphData: GraphData.EMPTY, cs: CoroutineScope, disposable: Disposable): String =
    outboundTransition
}